// 推荐活动

import Taro from '@tarojs/taro'
import { useEffect, useState } from 'react';
import { useSelector } from 'react-redux'
import { View, Text, Block } from '@tarojs/components'
import { getRecommendActivityList } from '../../../service/data'


import { } from './maxmodule'
import './mall.less'

function Activity() {
  const cardId = useSelector(state => state.card.__cardId);
  const [activityList, setActivityList] = useState([])


  useEffect(() => {
    if (!cardId) return
    const b = async () => {
      const res = await getRecommendActivityList({ cardId })
      setActivityList(res)
    }
    b()

  }, [cardId])

  if (activityList.length === 0) {
    return null
  }

  return (
    <Block >
      <View className='activity-module-wrap'>
        <View className='activity-module-header'>
          <Text className='activity-module-name'>推荐活动</Text>
          {/*  <navigator class='activity-module-link' url='/subs/interactive/pages/activity/activity?type=0'>更多<text class='iconfont icon-gerenziliaojiantou'></text></navigator>  */}
        </View>
        <View className='activity-module'>

          <View className='activity-items'>
            {activityList.map((item, index) => {
              return (
                <ActivityItem
                  key={item.index}
                  data={item}
                  onLiked={this.handleLike}
                  data-index={index}
                ></ActivityItem>
              )
            })
            }
          </View>
        </View>
      </View>
    </Block >

  )
}
export { Activity }